package strongholdCraft.common.Items.tool;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityEnderPearl;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.src.ModLoader;
import net.minecraft.world.World;
import strongholdCraft.common.Items.ItemTool;

public class ItemEndPickaxe extends ItemTool{
	
	MinecraftServer mcServer = MinecraftServer.getServer();
	int value = 0;
	int[] junk = {0,1,2,3,4,6};
	public static final Block[] blocksEffectiveAgainst = new Block[] {Block.cobblestone, Block.stoneDoubleSlab, Block.stoneSingleSlab, Block.stone, Block.sandStone, Block.cobblestoneMossy, Block.oreIron, Block.blockIron, Block.oreCoal, Block.blockGold, Block.oreGold, Block.oreDiamond, Block.blockDiamond, Block.ice, Block.netherrack, Block.oreLapis, Block.blockLapis, Block.oreRedstone, Block.oreRedstoneGlowing, Block.rail, Block.railDetector, Block.railPowered};
	public ItemEndPickaxe(int ID, EnumToolMaterial m, String name)
	{
		super(ID, 1, m, blocksEffectiveAgainst);
		setUnlocalizedName(name);
	}

	public boolean canHarvestBlock(Block par1Block)
	{
		return par1Block == Block.obsidian ? this.toolMaterial.getHarvestLevel() == 3 : (par1Block != Block.blockDiamond && par1Block != Block.oreDiamond ? (par1Block != Block.oreEmerald && par1Block != Block.blockEmerald ? (par1Block != Block.blockGold && par1Block != Block.oreGold ? (par1Block != Block.blockIron && par1Block != Block.oreIron ? (par1Block != Block.blockLapis && par1Block != Block.oreLapis ? (par1Block != Block.oreRedstone && par1Block != Block.oreRedstoneGlowing ? (par1Block.blockMaterial == Material.rock ? true : (par1Block.blockMaterial == Material.iron ? true : par1Block.blockMaterial == Material.anvil)) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2);
	}
	public float getStrVsBlock(ItemStack par1ItemStack, Block par2Block)
	{
		return par2Block != null && (par2Block.blockMaterial == Material.iron || par2Block.blockMaterial == Material.anvil || par2Block.blockMaterial == Material.rock) ? this.efficiencyOnProperMaterial : super.getStrVsBlock(par1ItemStack, par2Block);
	}
		
	public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
	{
			
		int oreValue = getOreValue(par3World, par4, par5, par6);
		ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Value: " + String.valueOf(oreValue));
		return false;
	}

	private int getOreValue(World W, int x, int y, int z) {
		for(int i=0; i<7; i++){
			for (int j = 0; j<7; j++){
				for(int k = 0; k<7; k++){
					
					int id = W.getBlockId(x+i, y+j, z+k);
					if ((junk.toString()).contains(String.valueOf(id))){
						value = value+1;
					}
					if (id == 56){
						value = value+100;
					}else{
						value = value+1;
					}
				}
			}
		}
			value = value/(7^3);
		return value;

	}

}



